package com.cy.cuiyang_admin.controller;

import com.cy.cuiyang_admin.rabbitmp.HelloReceiver;
import com.cy.cuiyang_admin.rabbitmp.HelloSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author cuiyang
 * @title: RabbitOneToOneTest
 * @projectName cuiyang
 * @description:
 *  * 备注：单生产者-单消费者
 * @date 2020/12/27 11:14
 */
@RestController
@RequestMapping("mq/")
public class RabbitOneToOneTest {

    @Resource
    private HelloSender helloSender;

    @Resource
    private HelloReceiver helloReceiver;

    /**
     * 生产者发送消息
     */
    @GetMapping("/hello")
    public void hello(){
        helloSender.send();
    }

    /**
     * 消费者消费消息
     */
    @GetMapping("/hello2")
    public void hello2(){
        helloReceiver.process("hello");
    }
}
